<?php

use App\Api\ArticleController;
use App\Api\CaptchaController;
use App\Api\CategoryController;
use App\Api\ConfigController;
use App\Api\ContentController;
use App\Api\LoginController;
use App\Api\MenuController;
use App\Api\OrderController;
use App\Api\ServiceController;
use App\Api\SlideController;
use App\Api\SmsController;
use App\Api\StaffController;
use App\Api\SystemNotiftyController;
use App\Api\TemplateController;
use App\Api\UploadController;
use App\Api\UserController;
use Illuminate\Support\Facades\Route;

//管理员

Route::post('user/login', [LoginController::class, 'login']);
Route::post('user/logout', [LoginController::class, 'logout']);

Route::get('user/info', [UserController::class, 'info']);

Route::get('captcha', [CaptchaController::class, 'make']);

//后台管理

Route::group(['prefix' => 'admin/', 'middleware' => ['auth:sanctum']], function () {

    //文章模型管理
    Route::apiResource('article', ArticleController::class);
    //栏目管理
    Route::Resource('category', CategoryController::class);
    //按栏目分类查找文章
    Route::get('category/{category}/content', [CategoryController::class, 'filter']);
    //文章模糊搜索
    Route::post('content/fuzzy', [ContentController::class, 'fuzzy']);

    //文章模板
    Route::get('template', [TemplateController::class, 'index']);
    Route::post('template/choose', [TemplateController::class, 'choose']);
    //文章
    Route::apiResource('content', ContentController::class);

    //系统通知消息
    Route::apiResource('system/notify', SystemNotiftyController::class)->only(['index', 'show']);

    //获取系统配置
    Route::get('config', [ConfigController::class, 'info']);
    //修改系统配置
    Route::post('config/update', [ConfigController::class, 'change']);
    //获取短信配置
    Route::get('sms', [SmsController::class, 'showsms']);
    Route::put('sms', [SmsController::class, 'putsms']);

    //订单
    Route::get('order/process', [OrderController::class, 'process']);
    Route::get('order/archive', [OrderController::class, 'archive']);
    //添加约束，相同手机号每分钟发多少条限制
//    Route::post('order', [OrderController::class, 'store'])->middleware(['throttle:sms']);
    Route::resource('order', OrderController::class);
//金牌员工
    Route::resource('staff', StaffController::class);
    //轮播

    Route::resource('slide', SlideController::class);

    //生成菜单

    Route::post('menu/generate', [MenuController::class, 'generate']);
//服务
    Route::resource('service', ServiceController::class);

});
//系统功能，本地上传
Route::post('upload/local', [UploadController::class, 'local']);

/**
 * wangEditor编辑器上传
 */
Route::post('upload/wangeditor', [UploadController::class, 'wangEditor']);
